' ***^^^***|||***^^^***
' 
'  This file is regenerated until it's edited. Delete the file to force regeneration.

'  NOTE: This denotes the way the file was created and it's possible the 
'        generation type has since changed.
'        Check the generation script for the curent state of the file.

' %%%###%%%26e96b67616b18853258284cd1927a81%%%###%%%
' %%%##NoWS##%%%04cf719b2c8954ba0f029270a21450d1%%%##NoWS##%%%
' ***^^^***|||***^^^***

  
'************************************************************************************
' Copyright © 2003-2006 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************

Option Explicit On
Option Strict On

Imports System
Imports System.Collections.Generic
Imports KadGen.Utility2005



Public Class DbsDataStructure
   Public Function GetRetrieveStoredProcs() As DbsStoredProcCollection
      Dim ret As New DbsStoredProcCollection
      For Each sp As DbsStoredProc In Me.DbsStoredProcs
         If sp.Type = Constants.retrieveString Then
            ret.Add(sp)
         End If
      Next
      Return ret
   End Function

   Public Function GetSetSelectStoredProcs() As DbsStoredProcCollection
      Dim ret As New DbsStoredProcCollection
      For Each sp As DbsStoredProc In Me.DbsStoredProcs
         If sp.Type = Constants.setSelectString Then
            ret.Add(sp)
         End If
      Next
      Return ret
   End Function

   Public Function GetSelectStoredProc(ByVal spName As String) As DbsStoredProc
      For Each sp As DbsStoredProc In Me.DbsStoredProcs
         If sp.Type = Constants.retrieveString And sp.Name = spName Then
            Return sp
         End If
      Next
      Return Nothing
   End Function

   Public Function GetTable(ByVal tableName As String) As DbsTable
      Return Me.DbsTables(tableName)
   End Function

   Public Function GetViewOrTable(ByVal tableName As String, ByVal viewName As String) As IViewOrTable
      Dim viewOrTable As IViewOrTable = Me.GetTable(tableName)
      If viewOrTable Is Nothing Then
         viewOrTable = Me.GetView(viewName)
      End If
      Return viewOrTable
   End Function

   Public Function GetView(ByVal name As String) As DbsView
      For Each view As DbsView In Me.DbsViews
         If view.Name = name Then
            Return view
         End If
      Next
      Return Nothing
   End Function

   Public Function GetTableColumn( _
               ByVal tableName As String, _
               ByVal columnName As String) _
               As DbsTableColumn
      Dim table As DbsTable = GetTable(tableName)
      If table Is Nothing Then
         Return Nothing
      End If
      Return table.DbsTableColumns.GetTableColumn(columnName)
   End Function


End Class

Public Class DbsDataStructureCollection

   Public Function GetTable(ByVal tableName As String) As DbsTable
      For Each datastructure As DbsDataStructure In Me
         Dim dbsTable As DbsTable = datastructure.GetTable(tableName)
         If dbsTable IsNot Nothing Then
            Return dbsTable
         End If
      Next
      Return Nothing
   End Function

   Public Function GetView(ByVal name As String) As DbsView
      For Each datastructure As DbsDataStructure In Me
         For Each view As DbsView In datastructure.DbsViews
            If view.Name = name Then
               Return view
            End If
         Next
      Next
      Return Nothing
   End Function

   Public Function GetTableColumn( _
               ByVal tableName As String, _
               ByVal columnName As String) _
               As DbsTableColumn
      Dim table As DbsTable = GetTable(tableName)
      If table Is Nothing Then
         Return Nothing
      End If
      Return table.DbsTableColumns.GetTableColumn(columnName)
   End Function

End Class

	